<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 输出对象属性1234567和值abcde
      /*
        1a
        23b
        24c
        256d
        257e
      */
      const obj = {
        1: "a",
        2: {
          3: "b",
          4: "c",
          5: {
            6: "d",
            7: "e",
          },
        },
      };
      // 递归
      for (let i in obj) {
        if (typeof obj[i] !== "object") {
          console.log(i, obj[i]);
        } else {
          for (let j in obj[i]) {
            if (typeof obj[i][j] !== "object") {
              console.log(i, j, obj[i][j]);
            } else {
              for (let h in obj[i][j]) {
                if (typeof obj[i][j][h] !== "object") {
                  console.log(i, j, h, obj[i][j][h]);
                } else {
                }
              }
            }
          }
        }
      }
    </script>
  </body>
</html>
